<template>
  <div>
    <c-title :hide="false" text="限时抢购"></c-title>
    <div class="purchase-head">
      <div class="flex-a-c" style="">
        <span class="text-class">结束倒计时：</span>
        <van-count-down use-slot :time="purchaseTime" @change="onTimeChange">
          <template #default="timeData">
            <span class="time-item" v-if="timeData.days > 0">{{ timeData.days < 10 ? `0${timeData.days}`:timeData.days }}天</span>
            <span class="write">:</span>
            <span class="time-item">{{ timeData.hours < 10 ? `0${timeData.hours}`:timeData.hours }}</span>
            <span class="write">:</span>
            <span class="time-item">{{ timeData.minutes < 10 ? `0${timeData.minutes}`:timeData.minutes }}</span>
            <span class="write">:</span>
            <span class="time-item">{{ timeData.seconds < 10 ? `0${timeData.seconds}`:timeData.seconds }}</span>
          </template>
        </van-count-down>
      </div>
    </div>
    <div class="goods-list" v-if="goods.length > 0">
      <div class="goods-item" v-for="(item, index) in goods" :key="index" @click="goodsNavTo(item.id)">
        <div class="left">
          <img :src="item.thumb" alt="" />
        </div>
        <div class="right">
          <div class="title">{{ item.title }}</div>
          <div class="store">
            <img :src="item.logo" alt="" />
            <div class="name">{{ item.name }}</div>
          </div>
          <div class="rightBottom">
            <div class="rightBottom_left">
              <div class="price">{{ item.product_price }}</div>
              <div class="price_d">{{ item.market_price }}</div>
            </div>
            <div class="btn">抢购</div>
          </div>
        </div>
      </div>
    </div>
    <van-empty description="暂无数据" v-else />
  </div>
</template>
<script>
import purchase_controller from "./purchase_controller.js";
export default purchase_controller;
</script>
<style scoped lang="scss">
.purchase-head {
  height: 3rem;
  padding: 0 0.75rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  .write {
    padding: 0 0.125rem;
    color: #e32323;
  }
  .time-item {
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1.0625rem;
    color: #fff;
    padding: 0.25rem;
    background-color: #e32323;
    border-radius: 0.3rem;
  }
}
.text-class {
  font-size: 0.88rem;
  line-height: 1.0625rem;
  color: #000;
}
.goods-list {
  padding: 0 0rem 0.5rem 0rem;
  .goods-item {
    margin: 0 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 0.75rem;
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    .right {
      flex: 1;
      margin-left: 0.5rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      overflow: hidden;
      .rightBottom {
        display: flex;
        justify-content: space-between;
        .btn {
          font-size: 0.75rem;
          color: #ffffff;
          padding: 0.25rem 1.25rem;
          border-radius: 1.09rem;
          background: #e32323;
        }
        .rightBottom_left {
          display: flex;
          align-items: flex-end;
          .price {
            font-size: 1rem;
            color: #e32323;
            font-weight: bold;
          }
          .price_d {
            text-decoration: line-through;
            color: #999999;
            font-size: 0.75rem;
            margin-left: 0.25rem;
          }
        }
      }
      .title {
        font-size: 0.88rem;
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .store {
        display: flex;
        align-items: center;
        overflow: hidden;
        img {
          flex-shrink: 0;
          width: 1rem;
          height: 1rem;
          border-radius: 100%;
          margin: 0;
          margin-right: 0.25rem;
        }
        .name {
          text-align: left;
          flex: 1;
          font-size: 0.75rem;
          color: #999999;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .left {
      width: 5.28rem;
      height: 5.28rem;
      border-radius: 0.25rem;
      img {
        width: 100%;
        height: 100%;
        border-radius: 0.25rem;
      }
    }
  }
}
.write {
  color: #fff;
}
</style>
